<?php
apf_require_class('Dao_DAO');

class Dao_Attendance_UserInfo extends DAO{
    public function get_table_name(){
        return 'user_info';
    }

    public function get_read_pdo_name(){
        return 'attendance_slave';
    }

    public function get_write_pdo_name(){
        return 'attendance_master';
    }

    public function get_table_pk(){
        return 'user_id';
    }

    /**
     * 获取所有销售人员和非上海人员
     */
    public function get_sale_and_not_in_shanghai(){
        $result = array();
        //销售人员
        $sql = "SELECT user_id,department_name,department_id FROM user_info WHERE department_name LIKE '%销售%'";
        $sales = $this->execute($sql,array(),$this->get_write_pdo_name());
        //非上海员工
        $sql = "SELECT user_id FROM user_info WHERE city_name!='上海' AND city_name!=''";
        $not_shanghai = $this->execute($sql,array(),$this->get_write_pdo_name());
        //特殊班别
        $sql = "SELECT user_id,user_type_date FROM user_info WHERE user_type=1";
        $special = $this->execute($sql,array(),$this->get_write_pdo_name());
        $sale_department = APF::get_instance()->get_config('sale_department');
        foreach ($sales as $one){
            if(!empty($sale_department[$one['department_id']])){
                $result['sales'][$one['user_id']] = $one['user_id'];
            }
        }
        foreach ($not_shanghai as $one){
            $result['nsh'][$one['user_id']] = $one['user_id'];
        }
        foreach ($special as $one){
            $result['special'][$one['user_id']] = $one;
        }
        unset($sales);
        unset($special);
        unset($not_shanghai);
        return $result;
    }
}